<script>
//get方式
let xhr = new XMLHttpRequest()
xhr.open('GET', '/server')
xhr.send()
xhr.onreadystatechange = function(){
    if(this.readyState === 4){
        if(this.status === 200){
            console.log(this.response)
        }
    }
}

//post方式
let xhr = new XMLHttpRequest()
xhr.open('post', '/server')
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.send({name: 'gailun', age: 15})
xhr.onreadystatechange = function(){
    if(this.readyState === 4){
        if(this.status === 200){
            console.log(this.responseText)
        }
    }
}



</script>